package com.fourth.service.impl;/**
 * Created by Administrator on 2019/6/21.
 */


import com.fourth.entity.Orders;
import com.fourth.service.OrdersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * RabbitMQ通用的消息接收服务
 * @Author:debug (SteadyJack)
 * @Date: 2019/6/21 21:47
 **/
@Service
public class RabbitReceiverService {

    public static final Logger log= LoggerFactory.getLogger(RabbitReceiverService.class);

    @Autowired
    private Environment env;

    @Autowired
    private OrdersService ordersService;


    /**
     * 用户确认订单成功后超时未支付-监听者
     * @param orders
     */
//    @RabbitListener(queues = {"${mq.kill.item.success.kill.dead.real.queue}"},containerFactory = "singleListenerContainer")
//    public void consumeExpireOrder(List<Orders> orders){
//        try {
//            log.info("用户确认订单成功后超时未支付-监听者-接收消息:{}",orders);
//
//            for (Orders order : orders) {
//                if (order!=null){
//                    List<Orders> selectOrdersOStatus=ordersService.selectOrdersByONo(order.getONo());
//
//                    int oStatus=0;
//                    for (Orders ordersOStatus : selectOrdersOStatus) {
//                        oStatus = ordersOStatus.getOStatus();
//                    }
//                    if (selectOrdersOStatus!=null && oStatus==0){
//                        System.out.println("订单状态为0：修改==》"+oStatus);
//                        ordersService.updateOrdersByoNo(order.getONo());
//                    }else{
//                        System.out.println("订单状态不是未支付状态了");
//                    }
//
//                }
//            }
//
//        }catch (Exception e){
//            log.error("用户确认订单成功后超时未支付-监听者-发生异常：",e.fillInStackTrace());
//        }
//    }


}












